<!--
 * @Descripttion: 登录授权页
 * @version: 
 * @Author: ck
 * @Date: 2021-05-06 09:52:45
 * @LastEditors: ck
 * @LastEditTime: 2021-05-26 17:58:37
-->
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        var menus = [
            {
                "id": 5,
                "pid": 0,
                "menuType": 1,
                "title": "系统管理",
                "icon": "el-icon-menu",
                "menuUrl": "/sysManage",
                "permission": "menu:list",
                "menuSort": 3,
                "componentUrl": "Layout",
                "hasShow": false,
                "children": [
                    {
                        "id": 7,
                        "pid": 5,
                        "menuType": 1,
                        "title": "角色管理",
                        "icon": "el-icon-menu",
                        "menuUrl": "roles",
                        "permission": "roles:list",
                        "menuSort": 2,
                        "componentUrl": "roles",
                        "hasShow": false,
                        "children": []
                    },
                    {
                        "id": 8,
                        "pid": 5,
                        "menuType": 1,
                        "title": "用户管理",
                        "icon": "el-icon-menu",
                        "menuUrl": "user",
                        "permission": null,
                        "menuSort": 1,
                        "componentUrl": "user",
                        "hasShow": false,
                        "children": []
                    }
                ]
            },
            {
                "id": 6,
                "pid": 0,
                "menuType": 2,
                "title": "管理2",
                "icon": "el-icon-menu",
                "menuUrl": "/sysManage",
                "permission": "menu:list",
                "menuSort": 1,
                "componentUrl": "Layout",
                "hasShow": false,
                "children": []
            }
        ];
        var getParentNodes = function (nodes, curNode) {
            nodes = nodes.concat();
            let parentNodes = [];
            nodes.forEach((node, i) => {
                if (curNode.pid == node.id) {
                    parentNodes.push(node);
                    nodes.splice(i, 1);
                    parentNodes = parentNodes.concat(getParentNodes(nodes, node));
                }
            });
            return parentNodes;
        }
        console.log(menus)
    </script>
</body>

</html>